/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.room.handler;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import extension.room.phom.PhomExtension;
import extension.room.phom.PhomGame;
import extension.room.phom.PhomPlayer;
import log.Debug;

/**
 *
 * @author daz
 */
public class DepositCardHandler extends BaseClientRequestHandler {

    @Override
    public void handleClientRequest(User user, ISFSObject params) {
        Debug.d("deposit card handler :" + user.getName());
        PhomExtension phomExtension = (PhomExtension) getParentExtension();
        PhomGame game = phomExtension.getGame();
        PhomPlayer p = game.getPlayerFight();
        if (p.getName().equals(user.getName())) {
            game.depositCard();
            phomExtension.getResponse().sendDepositCard(p.getSeatPos(), p.getListDepositCard(), p.getListDepositTarget());
            if (p.getListCards().isEmpty()) {
                game.onFinishU(PhomGame.NOT_HAVE_PHOM);
            }
        }
    }
}
